home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d1
/
batchlrn.arc
/
FOR.HLP
< prev
next >
Wrap
Text File
|
1991-06-17
|
5KB
|
69 lines
* *
* *
* *
* *
* *
|---------------B A T C H L R N H E L P S Y S T E M-----------------|
|command: FOR |
|use: The FOR command is used to expand the power of a batch file |
| command or as an interactive (from the keyboard prompt) command |
|how: In Batch processing type: FOR %%<c>IN<set>DO<command> |
| In Interactive processing type: FOR %<c>IN<set>DO<command> |
| (Did you say Huh? You demand...and get, a translation...) |
|translation: %%<c> or %<c> is a variable. <c> can be any character |
| except 0,1,2,3...,9. This avoids confusion with the %0-%9 batch pa- |
| ramaters. <set> is a list of items separated by spaces and enclosed |
| in parentheses. For example:: (item1 item2 item3...itemN) is a set. |
| The %%<c> variable is set sequentially to each member of the <set>, |
| and then <command> is performed. If a member of <set> is an express-|
| ion involving either * or ?, or both, then the varible is set to |
| each matching pattern from the file. In this case, only one such |
| <item> may be in the set. Any <item> other than the first <item> is |
| ignored. |
| (We KNOW this is DIFFICULT, but STAY with us!). . . |
|explanation: The translation is complex,but UNTIL YOU UNDERSTAND IT, |
| SO is the FOR command. For that reason,AFTER you have finished this |
| .HLP file go to FORINDO.HLP which has examples & explanations(They |
| are NO GOOD, however, unless you understand the overall concept)! |
| The FOR command is similar to the "for..next loop" that programm-|
| ers use to repeat a paricular action a given number of times. The |
| FOR file to compare files on A: & B: drives looks like this: |
| FOR %X IN (*.*) DO IF EXIST B:%X ECHO %X IS ON BOTH A:&B: |
| | | |=the<command>(here, starting on A:drive, the |
| | | DO sees IF X {which is *.*[any of all the |
| | | files on A:]} exists on B: the ECHOes the |
| | | file name {X} as being on "BOTH A:&B:") |
| | | |
| | |=IN<set> the set is *.* or all the files on A:&B: |
| | |
| |=FOR is seeking the variable %X (it could be any letter) |
| |
| (It should be starting to get clearer) |
| What we have displayed is an interactive FOR command string. If |
| it were in a two-line batch file (for example) the first line would |
| be ECHO OFF to keep command clutter off the screen. ALSO,in a batch |
| file %X would be %%X (this tells DOS this is NOT a marker. It also |
| leaves one % after multiple parameter processing {seeFORINDO>HLP}). |
|examples: SEE THE FORINDO.HLP FILE FOR EXAMPLES & EXPLANATIONS! |
| |
|notes: Remember, in a batch file, you must use the expression "%%". |
| If you are in interactive DOS processing mode,only ONE % is needed. |
| You cannot nest FOR commands in DOS like the FOR-NEXT command is |
| used in GWBASIC. If you try to do this, the message: |
| "FOR cannot be nested" |
| appears when you are running your batch program. The program will |
| not perform as you expected. |
| (SET) is one or more filenames or commands you want %%Varible to |
| assume while the command is being executed. Use a space between |
| entries, and pathnames are not allowed. Don't folrget the parenthe- |
| sis around the set. Wildcards may be used within (SET) if you are |
| using filenames. |
| Command is the particular DOS command or batch subcommand you want |
| to have performed. Usually one or more of these commands will |
| contain the %%Varible in it. If (SET) contains DOS commands, only |
| %%Varible is used. |
| In effect, what this subcommand does is cause %%Varible to be an |
| index into the (SET) for use by command. |
| |
|----------------- T I M E M A S T E R ---------------------|